package com.weibo.util;

import java.util.HashMap;
import java.util.List;

import weibo4android.Count;
import weibo4android.Status;
import weibo4android.WeiboException;

import com.weibo.Sina;

public class GetWeiboCount {
	
	public static HashMap<Long, Count> getCounts(List<Status> sList) {
		HashMap<Long, Count> counts = new HashMap<Long, Count>();
		StringBuffer buffer = new StringBuffer();
		for (int i = 0; i < sList.size(); i++) {
			buffer.append(sList.get(i).getId() + ",");
		}
		try {
			List<Count> count = Sina.getInstance().getWeibo()
					.getCounts(buffer.substring(0, buffer.length() - 1));
			for (int i = 0; i < count.size(); i++) {
				counts.put(count.get(i).getId(), count.get(i));
			}
		} catch (WeiboException e) {
			e.printStackTrace();
		}
		return counts;
	}

	public static HashMap<Long, Count> appendCounts(List<Status> sList, HashMap<Long, Count> counts) {
		StringBuffer buffer = new StringBuffer();
		for (int i = 0; i < sList.size(); i++) {
			buffer.append(sList.get(i).getId() + ",");
		}
		try {
			List<Count> count = Sina.getInstance().getWeibo()
					.getCounts(buffer.substring(0, buffer.length() - 1));
			for (int i = 0; i < count.size(); i++) {
				counts.put(count.get(i).getId(), count.get(i));
			}
		} catch (WeiboException e) {
			e.printStackTrace();

		}
		return counts;
	}
}
